package com.jyu.apts.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="organizationRole",uniqueConstraints= {@UniqueConstraint(name="organizationRole_name_organization",columnNames= {"name","organization_id"})})
public class OrganizationRole {

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	long id;//主键
	@Column
	String name;//名称
	@OneToMany(mappedBy="organizationRole",cascade={CascadeType.REMOVE})
	List<User> users;
	@ManyToMany
	List<Item> items;//分配的流程
	@ManyToMany
	List<ItemProcess> itemProcesses;//分配的流程
	@ManyToMany
	List<ItemProductionLine> itemProductionLines;//分配的生产线
	@ManyToOne
	Organization organization;
}
